package com.atguigu.practice;

import java.util.Scanner;

public class ReversePartListNode {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        //节点个数
        int n=scanner.nextInt();
        ListNode head=new ListNode(scanner.nextInt());
        n--;
        ListNode cur=head;
        while(n>0){
            cur.next=new ListNode(scanner.nextInt());
            cur=cur.next;
            n--;
        }
        //初始化成功
        int left=scanner.nextInt();
        int right=scanner.nextInt();
        cur=head.next;
        head.next=null;
        ListNode node=null;
        while(n<right-left && cur!=null){ //需要对头结点前插的节点个数
            node=cur.next;
            cur.next=head;
            head=cur;
            cur=node;
            n++;
        }
        cur=head;
        while(cur.next!=null){
            cur=cur.next;
        }
        cur.next=node;
        cur=head;
        while(cur!=null){
            System.out.print(cur.val+" ");
            cur=cur.next;
        }
    }
}

